package com.example.meetingroomnew.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.meetingroomnew.Dao.MeetingRoomDao;
import com.example.meetingroomnew.domain.MeetingRoom;
import org.apache.ibatis.jdbc.Null;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MeetingRoomServiceImpl implements MeetingRoomService {
    @Autowired
    MeetingRoomDao meetingRoomDao;

    @Override
    public List<MeetingRoom> selectAll() {

        List<MeetingRoom> meetingRooms = meetingRoomDao.selectList(null);

        return meetingRooms;
    }

    @Override
    public List<MeetingRoom> selectByname(String name, String roomNumber) {
        LambdaQueryWrapper<MeetingRoom> qw=new LambdaQueryWrapper<MeetingRoom>();
        qw.like(MeetingRoom::getName,name);
        qw.like(MeetingRoom::getRoomNumber,roomNumber);
        List<MeetingRoom> meetingRooms = meetingRoomDao.selectList(qw);
        return meetingRooms;
    }

    @Override
    public boolean deletemeetingRoom(int id) {
        meetingRoomDao.deleteById(id);
        return true;
    }

    @Override
    public boolean InsertmeetingRoom(MeetingRoom meetingRoom) {
        meetingRoomDao.insert(meetingRoom);
        return true;

    }

    @Override
    public boolean update(MeetingRoom meetingRoom) {
        meetingRoomDao.updateById(meetingRoom);
        return true;
    }

    @Override
    public MeetingRoom selectByid(int id) {
        MeetingRoom meetingRoom = meetingRoomDao.selectById(id);
        return meetingRoom;
    }
}
